package magicboard.view.action
{
	import flash.system.System;
	
	import magicboard.model.GeometryObject;
	import magicboard.view.Board;
	
	import mx.controls.Alert;
	
	public class CopyAction implements Action
	{
		// --------------------------------------------------------------------------------------------
		public function CopyAction(board:Board){
			_board = board
		}

		// --------------------------------------------------------------------------------------------
		public function execute():void{
			var text:String;
			var obj:GeometryObject;
			var index:int;
			var currentDate:Date = new Date();
			
			text = "# Test data generated on: " + currentDate + "\n";
			
			text += "[input]\n";
			text += _board.lastObject.saveToString() + "\n\n";
			text += "[model]\n";
    	for(index = 0; index < _board.boardModel.objects.length-1; index++){
    		obj = _board.boardModel.objects[index];
				text += obj.saveToString() + "\n";
    	}	
			text += "\n[output]\n";
			obj = _board.boardModel.objects[index];
			text += "type:" + obj.getType() + "\n";

			System.setClipboard(text);
			Alert.show("Text was copied to the clipbard", "Message");
		}
		
		
		// --------------------------------------------------------------------------------------------
		// Private members
		private var _board:Board;
	}
}